//
//  UIImageView+Extension.swift
//  LEOweibo
//
//  Created by zz on 16/3/6.
//  Copyright © 2016年 zz. All rights reserved.
//

import UIKit
import SDWebImage
extension UIImageView {
    
    ///构造函数
    convenience init(leoImage leoImageName: String) {
        
        self.init(image: UIImage(named: leoImageName))
    }
    ///设置图像
    func leoSetImage(urlString: String?, placeholder: String?) {
        
        var placeholderImage: UIImage?
        if placeholder != nil {
            placeholderImage = UIImage(named: placeholder!)
        }
        guard let urlString = urlString,
            let url = NSURL(string: urlString) else{
                image = placeholderImage
                return
        }
        
        sd_setImageWithURL(url, placeholderImage: placeholderImage)
    }

}
